<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    ul {
      list-style: none;
    }

    .mi {
      position: relative;
      width: 223px;
      height: 48px;
      border: 1px solid #ccc;
      border-radius: 5px;
      font-size: 14px;
      line-height: 30px;
      outline: none;

    }

    .mi input {
      width: 223px;
      height: 48px;
      padding: 0 10px;
      font-size: 14px;
      line-height: 48px;
      border: 1px solid #ccc;
      outline: none;
    }

    .mi .search {
      border: 1px solid #cf1c1c;
    }

    .result-list {
      display: none;
      position: absolute;
      left: 0;
      top: 48px;
      width: 223px;
      border: 1px solid #ccc;
      border-top: 0;
      background-color: #f5f1f1;
    }

    .result-list a {
      display: block;
      padding: 6px 15px;
      font-size: 12px;
      color: #000;
      text-decoration: none;
    }

    .result-list a:hover {
      background-color: #eee;
    }
  </style>
</head>

<body>
  <div class="mi">
    <input type="search" class="search" placeholder="请输入搜索内容">
    <ul class="result-list">
      <li><a href="">1</a></li>
      <li><a href="">2</a></li>
      <li><a href="">3</a></li>
      <li><a href="">4</a></li>
      <li><a href="">5</a></li>
      <li><a href="">6</a></li>
    </ul>
  </div>
</body>
<script>
  const input = document.querySelector('.mi input');
  const resultList = document.querySelector('.result-list');
  input.addEventListener('focus', function () {
    resultList.style.display = 'block';
    input.classList.add('search');
  })
  input.addEventListener('blur', function () {
    resultList.style.display = 'none';
    input.classList.remove('search');
  })
</script>

</html>